import requests
from bs4 import BeautifulSoup
with open('道诡异仙2.text', 'w', encoding='utf8') as f:
    for i in range(37045043, 43849089):
        for j in range(1,5):
            url = f'http://wap.xbiqugu.net/wapbook/96635_{i}_{j}.html'
            print(url)
            r = requests.get(url)
            if r.status_code==200:
                r.encoding = r.apparent_encoding
                soup = BeautifulSoup(r.text,'html.parser')
                contents = soup.select('#nr')
                for content in contents:
                    # titile = content.select('title').get_text()
                    book = content.select('#nr1')[0].get_text()
                    f.write(book)
            else:
                print('失败')